{% extends "base.html" %}

{% block title %}创作者中心{% endblock %}

{% block content %}
<div class="container mt-4">
    <h2>创作者中心</h2>
    <div class="row">
        <div class="col-md-4">
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">个人资料</h5>
                    <p class="card-text">{{ profile.bio or '暂无简介' }}</p>
                    <p><strong>专长领域:</strong> {{ profile.specialty or '未设置' }}</p>
                    {% if profile.social_links %}
                    <p><strong>社交媒体:</strong> {{ profile.social_links }}</p>
                    {% endif %}
                    <a href="{{ url_for('account_security') }}" class="btn btn-sm btn-outline-primary">编辑资料</a>
                </div>
            </div>
        </div>
        <div class="col-md-8">
            <div class="card mb-4">
                <div class="card-body">
                    <h5 class="card-title">最近内容</h5>
                    <div class="list-group">
                        {% for content in contents %}
                        <div class="list-group-item">
                            <div class="d-flex w-100 justify-content-between">
                                <h6 class="mb-1">{{ content.title }}</h6>
                                <small>{{ content.created_at.strftime('%Y-%m-%d') }}</small>
                            </div>
                            <p class="mb-1">{{ content.description|truncate(100) }}</p>
                            <span class="badge bg-{{ 'success' if content.status == 'published' else 'warning' }}">
                                {{ content.status }}
                            </span>
                            <a href="{{ url_for('edit_content', content_id=content.id) }}" class="btn btn-sm btn-outline-secondary ms-2">编辑</a>
                        </div>
                        {% else %}
                        <div class="list-group-item">
                            <p class="mb-0">暂无内容</p>
                        </div>
                        {% endfor %}
                    </div>
                    <a href="{{ url_for('manage_content') }}" class="btn btn-primary mt-3">管理所有内容</a>
                </div>
            </div>
            
            <div class="card">
                <div class="card-body">
                    <h5 class="card-title">最近收益</h5>
                    <table class="table table-sm">
                        <thead>
                            <tr>
                                <th>日期</th>
                                <th>金额</th>
                                <th>来源</th>
                                <th>状态</th>
                            </tr>
                        </thead>
                        <tbody>
                            {% for earning in earnings %}
                            <tr>
                                <td>{{ earning.transaction_date.strftime('%Y-%m-%d') }}</td>
                                <td>{{ earning.amount }}</td>
                                <td>{{ earning.source }}</td>
                                <td>{{ earning.status }}</td>
                            </tr>
                            {% else %}
                            <tr>
                                <td colspan="4" class="text-center">暂无收益记录</td>
                            </tr>
                            {% endfor %}
                        </tbody>
                    </table>
                    <a href="{{ url_for('view_earnings') }}" class="btn btn-primary">查看完整收益</a>
                </div>
            </div>
        </div>
    </div>
</div>
{% endblock %}
